package tests;

import static org.junit.Assert.*;

import org.junit.Test;

import entities.Inventory;
import fields.Tax;
import fields.Territory;
import gstd.Player;

public class TestTax {

	
	@Test
	public void testLandOnField() {
		Tax t = new Tax("Tax", 1000, 0.1);		
		Tax t2 = new Tax("Tax", 4000, 0.1);
		Territory f = new Territory("Territory", 2500, 2500);
		Territory f2 = new Territory("Territory", 5000, 5000);
		Territory f3 = new Territory("Territory", 10000, 10000);
		Territory f4 = new Territory("Territory", 20000, 20000);
		Player p = new Player("Mr. Cat", new Inventory(0));
		Player p2 = new Player("Mr. Dog", new Inventory(10000));
		
//		First test, tax is 1000 and 10% of 0 (Total value of assets) is 0 so the player will pay 0
		t.landOnField(p);
		assertEquals(0, ((Inventory)p.getInventory()).getBalance());
		
//		Second test, tax is 1000 and 10% of 10000 (Total value of assets) is 1000, so it will pay 1000
		t.landOnField(p2);
		assertEquals(9000, ((Inventory)p2.getInventory()).getBalance());
		
//		Third test, tax is 1000 and 10% of 20000 (Total value of assets) is 2000, it will therefore pay the tax
		f3.setOwner(p);
		((Inventory)p.getInventory()).addField(f4);
		t.landOnField(p);
		assertEquals(-1000, ((Inventory)p.getInventory()).getBalance());
		
//		Fourth test, tax is 4000 and 10% of 19000(Total value of assets) is 1900, it should pay the percentage
		System.out.println(p2.getInventory().getBalance());
		f3.setOwner(p2);
		((Inventory)p2.getInventory()).addField(f3);
		t2.landOnField(p2);
		assertEquals(7100, ((Inventory)p2.getInventory()).getBalance());
		
	}

}
